#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "dominion.h"

void testing(struct gameState *game);

int main(int argc, char *argv[])
{
	struct gameState *game = malloc(sizeof(struct gameState));

	testing(game);

	free(game);

	return 0;
}

void testing(struct gameState *game)
{
	struct gameState *after = malloc(sizeof(struct gameState));

	int h_size = 0;

	printf("UNIT TEST 1...........\n");
	printf("BEGIN TESTING SHUFFLE................\n\n");

	for(int i = 0; i < 10; i ++)
	{
		h_size = (rand() % 10) + 5;
		for(int j = 0; j < h_size; j++)
		{
			game->deck[0][j] = rand() % 27;
			game->deckCount[0]++;
		}
		memcpy(after, game, sizeof(struct gameState));

		printf("MEMORY COPIED\n");

		printf("SUFFLE WORKING......................\n");

		for(int k = 0; k <= MAX_PLAYERS; k++)
		{
			shuffle(k, game);
		}

		printf("Hand Size = %d\n", h_size);

		// assert(memcmp(game, after, sizeof(struct gameState)) == 0);
		
		if(memcmp(game, after, sizeof(struct gameState)) == 0)
		{
			printf("Test FAILED.\n");
		}
		else
		{
			printf("Test PASSED.\n");
		}
		printf("\n");
	}
	free(after);

	printf("TESTS COMPLETE....................\n");

	return;
}